package edu.whu.puppygo.util;

import edu.whu.puppygo.entity.User;
import lombok.extern.slf4j.Slf4j;

/**
 * @author guanruwang
 * @date 2023/11/13$
 */
@Slf4j
public class GlobalUser {
    private static ThreadLocal<User> globaluser = new ThreadLocal<>();

    public static User getUser() {
        return globaluser.get();
    }

    public static void setUser(User user) {
        globaluser.set(user);
        log.info("set user..............." + globaluser.get());
    }

    public static void clear() {
        globaluser.remove();
        log.info("clear user..............." + globaluser.get());
    }

}
